import os.path
import time

from line_profiler import LineProfiler # 逐行计算运行时间
# pip install line_profiler
# https://github.com/rkern/line_profiler
def get_logger():
    try:
        from loguru import logger
    except Exception as e:
        import pip
        pip.main(["install", "--user", "loguru"])
        from loguru import logger
        print(f'pip install loguru')
    # out_p = 'C:\zxc\data\shwj'
    out_p = './doc/log'
    # out_p = 'D:\code\git\zxc\huoni\shwj_honey'
    t = str(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()))
    logFile="%s/run_%s_%s.log" % (out_p, 'progname', t)
    #logger.add(logFile, rotation='200KB', compression='zip', retention="72h")
    logger.add(logFile, rotation='1024KB')

    return logger


def empty_decorator(func):
    return func

# isDebug = True
isDebug = False
logger = get_logger()
if isDebug:
    profiler = LineProfiler()
else:
    profiler = empty_decorator

if os.path.exists("D:\data\project_fubahanxi_local_computer.txt"):
    ROOTPATH = "D:\\"
else:
    ROOTPATH = "D:\\ZXC\\" # 客户机


print(f'isDebug: {isDebug}')
print(f'ROOTPATH: {ROOTPATH}')
if __name__ =='__main__':
    # test_HuoniMessClient()
    logger.info('test log info')